"""
#!!===========================================================
#版权（C）2023, Huawei Technologies Co., HUTAF xDevice
#!!===========================================================
#文 件 名:      SecurityUserIamAuthWidgetHapApi.py
#文件说明:      认证场景选择公共AW
#作   者:
#生成日期:
#!!===========================================================
"""

# -*- coding: utf-8 -*-
from devicetest.core.test_case import TestCase
from devicetest.aw.OpenHarmony import CommonOH
from aw.Useriam.AuthWidget import SecurityUserIamAuthWidgetCommon


#@keyword
def setAPI(oh_device,type=0):
    """
    #======================================================================
    #   @Method:           setAPI(oh_device,type)
    #   @Precondition:     选择类型
    #   @Func:             使用测试hap拉起控件
    #   @Param:            type：0:API9,1:API8,2:API6,3:API10,默认值为0
    #   @Example:
    #======================================================================
    """
    SecurityUserIamAuthWidgetCommon.enterhapseeting(oh_device)
    if type == 0:
        CommonOH.touchByText(oh_device,"API9接口测试")
    elif type == 1:
        CommonOH.touchByText(oh_device,"API8接口测试")
    elif type == 2:
        CommonOH.touchByText(oh_device,"API6接口测试")
    elif type == 3:
        CommonOH.touchByText(oh_device,"API10接口测试")
    else:
        print("您输入的type值错误，请输入正确的type值")
        return False

def setface(oh_device):
    """
    #======================================================================
    #   @Method:           setface(oh_device)
    #   @Precondition:     预置条件
    #   @Func:             预置人脸
    #   @Example:
    #======================================================================
    """
    SecurityUserIamAuthWidgetCommon.enterhapseeting(oh_device)
    CommonOH.touchByText(oh_device,"凭据管理")
    CommonOH.touchByText(oh_device,"预置人脸")
    CommonOH.touchByText(oh_device,"返回")

def setfingerprint(oh_device):
    SecurityUserIamAuthWidgetCommon.enterhapseeting(oh_device)
    """
    #======================================================================
    #   @Method:           setfingerprint(oh_device)
    #   @Precondition:     预置条件
    #   @Func:             预置指纹          
    #   @Example:
    #======================================================================
    """
    CommonOH.touchByText(oh_device,"凭据管理")
    CommonOH.touchByText(oh_device,"预置指纹")
    CommonOH.touchByText(oh_device,"返回")

def deletface(oh_device):
    SecurityUserIamAuthWidgetCommon.enterhapseeting(oh_device)
    """
    #======================================================================
    #   @Method:           deletface(oh_device)
    #   @Precondition:     环境恢复
    #   @Func:             删除人脸          
    #   @Example:
    #======================================================================
    """
    CommonOH.touchByText(oh_device, "凭据管理")
    CommonOH.touchByText(oh_device, "删除人脸")
    CommonOH.touchByText(oh_device, "返回")

def deletefingerprint(oh_device):
    """
    #======================================================================
    #   @Method:           deletefingerprint(oh_device)
    #   @Precondition:     环境恢复
    #   @Func:             删除指纹
    #   @Example:
    #======================================================================
    """
    CommonOH.touchByText(oh_device, "凭据管理")
    CommonOH.touchByText(oh_device, "删除指纹")
    CommonOH.touchByText(oh_device, "返回")

def setAuthType(oh_device,authtype,trustlevel,title,Navigation,WindowModeType):
    """
    #======================================================================
    #   @Method:           setAuthType(oh_device)
    #   @Precondition:     认证类型
    #   @Func:             认证类型选择
    #   @Example:
    #======================================================================
    """
    CommonOH.inputTextByType(oh_device, "TextInput", authtype, 0)
    CommonOH.inputTextByType(oh_device, "TextInput", trustlevel, 1)
    CommonOH.inputTextByType(oh_device, "TextInput", title, 2)
    CommonOH.inputTextByType(oh_device, "TextInput", Navigation, 3)
    CommonOH.inputTextByType(oh_device, "TextInput", WindowModeType, 4)

def auth(oh_device,type=0):
    """
    #======================================================================
    #   @Method:           auth(oh_device,type)
    #   @Precondition:     拉起控件
    #   @Func:             拉起控件
    #   @Param:            type：0:默认值,1:调用on函数,2:调用off函数,3:调用start函数,4:调用cancel函数
    #   @Example:
    #======================================================================
    """
    if type == 0:
        CommonOH.touchByText(oh_device, "auth")
        CommonOH.touchByText(oh_device, "getAuthInstance")
    elif type == 1:
        CommonOH.touchByText(oh_device, "on")
        CommonOH.touchByText(oh_device, "getAuthInstance")
    elif type == 2:
        CommonOH.touchByText(oh_device, "off")
        CommonOH.touchByText(oh_device, "getAuthInstance")
    elif type == 3:
        CommonOH.touchByText(oh_device, "start")
        CommonOH.touchByText(oh_device, "getAuthInstance")
    elif type == 4:
        CommonOH.touchByText(oh_device, "cancel")
        CommonOH.touchByText(oh_device, "getAuthInstance")
    else:
        print("您输入的type值错误，请输入正确的type值")
        return False